Skip to content

Refactor 0-1 Knapsack Implementation #236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 8, 2024

Conversation

sozelfist
Copy link
Contributor

Improve code readability, maintainability and edge case handling.

  • Correctly throws an error if the length of the weights and values arrays are not equal
  • Use camelCase consistently through the codebase
  • Add type annotations to the function params and return types
  • Adding comments within the loops to clarify the logic
  • Ensure your function handles edge cases appropriately, such as when capacity is 0 or when weights and values arrays are empty

- Correctly throws an error if the length of the `weights` and `values` arrays are not equal
- Use camelCase consistently through the codebase
- Add type annotations to the function params and return types
- Adding comments within the loops to clarify the logic
- Ensure the function handles edge cases appropriately, such as when capacity is 0 or when weights and values arrays are empty
Copy link
Contributor

@appgurueu appgurueu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the refactor

@raklaptudirm raklaptudirm merged commit b4062be into TheAlgorithms:master Apr 8, 2024
2 of 3 checks passed
@sozelfist sozelfist deleted the ref/dp/0-1-knapsack branch April 8, 2024 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants